package com.example.ovulationperiodtracker.Allactivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.Toast;

import com.andrognito.pinlockview.PinLockListener;
import com.example.ovulationperiodtracker.R;
import com.example.ovulationperiodtracker.databinding.ActivityPinBinding;
import com.example.ovulationperiodtracker.utils.MyLog;
import com.example.ovulationperiodtracker.view.NoteUtils;
import com.gyf.immersionbar.ImmersionBar;
import com.necer.base.BaseActivity;

public class PinActivity extends BaseActivity<ActivityPinBinding> {
    @Override
    protected ActivityPinBinding createBinding(LayoutInflater inflater) {
        return ActivityPinBinding.inflate(inflater);
    }

    @Override
    protected void onCreated(Bundle savedInstanceState) {

        ImmersionBar.with(this).statusBarDarkFont(false).navigationBarColor(R.color.white).init();

        binding.pinLockView.setPinLength(4);
        binding.pinLockView.attachIndicatorDots(binding.indicatorDots);
        binding.pinLockView.setPinLockListener(new PinLockListener() {
            @Override
            public void onComplete(String pin) {
                String pw = NoteUtils.getPin();
                if (pw.equals(pin)) {
                    Intent intent = new Intent(context, MainActivity2.class);
                    startActivity(intent);
                    finish();
                }else{
                    Toast.makeText(context, "密码输入错误", Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onEmpty() {

            }

            @Override
            public void onPinChange(int pinLength, String intermediatePin) {

            }
        });
    }
}
